<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/WEB-INF/struts-tags.tld" prefix="s"%> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>喜乐康智能家居系统</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
  	<script type="text/javascript">
	  	function settingAdvancedScheduleListDown(upDown){
	
	  		settingDown("setting_advanced_device_schedule_list_detail","setting_advanced_device_left2_down",387,upDown);
	  	}
	
	  	function settingAdvancedScheduleListUp(upDown){
	  		settingUp("setting_advanced_device_schedule_list_detail","setting_advanced_device_left2_up",upDown);
	  		
		}

	  	function addPhoneNumber(upDown){
	  	  	if(upDown=='down'){
				$(".schedule_add_button").css("background-image","url('"+evn_Path+"resource/device_button_press.png')");
			}else if(upDown=='up'){
				$(".schedule_add_button").css("background-image","url('"+evn_Path+"resource/device_button.png')");
				var phoneNumber = $("#phoneNumber").val();
				if(phoneNumber==null || phoneNumber.trim()==''){
					alert("手机号码不能为空！");
					return ;
				}else{
					if(!(/^1[3|4|5|8][0-9]\d{8}$/.test(phoneNumber))){ 
						alert("不是完整的11位手机号"); 
						return ;
					}
				}
				var phoneName = $("#phoneName").val();
				if(phoneName==null || phoneName.trim()==''){
					alert("姓名不能为空！");
					return ;
				}else if(phoneName.length > 20){
					alert("姓名长度不能超过20个字符！");
					return ;
				}
				
				$.post(evn_Path+"setting!savePhone.do",{
					phoneNumber:phoneNumber,
					phoneName:phoneName,
					},
					function(data){
					if(data=='success'){
						$(".setting_advanced_right").load(evn_Path+"setting!settingAdvancedPhone.do");
					}
					})
			}
  	  	}

	  	function deletePhone(phoneId,upDown){
			if(upDown == 'down'){
				$("#schedule_list_delete"+phoneId).css("background-image","url('"+evn_Path+"resource/schedule_list_delete_press.png')");
			}else if(upDown == 'up'){
				if(confirm("你确定要删除吗？")){
					$.post(evn_Path+"setting!deletePhone.do",{phoneId:phoneId},
							function(data){
								if(data=="success"){
									$(".setting_advanced_right").load(evn_Path+"setting!settingAdvancedPhone.do");
								}else{
									$("#schedule_list_delete"+phoneId).css("background-image","url('"+evn_Path+"resource/schedule_list_delete.png')");
								}
							})
				}else{
					$("#schedule_list_delete"+phoneId).css("background-image","url('"+evn_Path+"resource/schedule_list_delete.png')");
				}
			//	
			}
		}

		function phoneNumberRest(upDown){
			if(upDown == 'down'){
				$(".schedule_add_reset").css("background-image","url('"+evn_Path+"resource/device_button_press.png')");
			}else if(upDown == 'up'){
				$("#phoneName").val("");
				$("#phoneNumber").val("");
				$(".schedule_add_reset").css("background-image","url('"+evn_Path+"resource/device_button.png')");
			}
			
		}
		
		function pressPhone(){
			$.get("callVK.do");
		}
  	</script>
  	
  </head>
  
  <body>
  	<div class="setting_advanced_count_left">
  		<div style="height: 397px;width: 304px;">
	  		<div class="setting_advanced_detail_left_bottom" style="height: 387px;">
	  			<div class="setting_advanced_device_schedule_list" style="height: 387px;">
	  				
	  					<div id="setting_advanced_device_room_list_detail1" class="setting_advanced_device_schedule_list_detail">
	  						<s:iterator id="phone" value="mobileNumber" status="status">
	  								<div class="setting_advanced_device_schedule_list_detail_text" >
	  									<div class="schedule_list_delete" id="schedule_list_delete<s:property value="id"/>" onmousedown="deletePhone(<s:property value="id"/>,'down')" onmouseup="deletePhone(<s:property value="id"/>,'up')"></div>
	  									<div style="float:left;width: 200px;margin-left: 5px;">
											姓名：<s:property value="name"/> 手机：<s:property value="number"/>
										</div>
	  									<div class="clear"></div>
									</div>
	  						</s:iterator>
	  					</div>
	  				
	  			</div>
	  			
	  		</div>
	  		<div class="setting_advanced_device_left2_up_down">
	  			<div onmouseup="settingAdvancedScheduleListUp('up')" onmousedown="settingAdvancedScheduleListUp('down')" class="setting_advanced_device_left2_up"></div>
	  			<div class="setting_advanced_device_left2_middle" style="height: 300px;"></div>
	  			<div onmouseup="settingAdvancedScheduleListDown('up')" onmousedown="settingAdvancedScheduleListDown('down')" class="setting_advanced_device_left2_down"></div>
	  		</div>
  		</div>
  		
  	</div>
	<div class="setting_advanced_device_right">
		<div style="margin-left: 20px;margin-top: 20px;height: 40px;text-align:left;line-height:40px;">
			<span style="font-size:15px;font-weight: bold;line-height:40px;width:80px;float:left;">姓&nbsp;&nbsp;&nbsp;&nbsp;名</span>
			<div style="width: 160px;float:left;margin-top: 8px;"><input type="text" value="" style="width: 150px;height: 25px;" name="phoneName" onclick="callVK();" id="phoneName"/></div>
		</div>
		<div style="margin-left: 20px;margin-top: 20px;height: 40px;text-align:left;line-height:40px;">
			<span style="font-size:15px;font-weight: bold;width:80px;float:left;">手机号码</span>
			<div style="width: 160px;float:left;margin-top: 8px;"><input type="text" value="" style="width: 150px;height: 25px;" name="phoneNumber" id="phoneNumber" onclick="callVK();"/></div>
		</div>
		<div class="schedule_add" style="margin-top: 50px;">
			<div class="schedule_add_button" onmousedown="addPhoneNumber('down')" onmouseup="addPhoneNumber('up')">增加</div>
			<div class="schedule_add_reset" onmousedown="phoneNumberRest('down')" onmouseup="phoneNumberRest('up')">重置</div>
		</div>
	</div>
  </body>
</html>
